package org.anlu.guava;

import com.google.common.reflect.Invokable;
import com.google.common.reflect.TypeToken;
import org.anlu.repo.StudentRepo;
import org.anlu.repo.StudentRepoImpl;
import org.anlu.repo.model.StudentPO;

import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * Description:TODO 详细描述
 * <p>
 * <p>
 *
 * @author anlu
 * @date 2024/1/8 17:35
 */
public class HelloGuava {

    public static void main(String[] args) {
        TypeToken<String> stringTok = TypeToken.of(String.class);
        TypeToken<Integer> intTok = TypeToken.of(Integer.class);


        TypeToken<List<String>> stringListTok = new TypeToken<List<String>>() {};

        TypeToken<Map<?, ?>> wildMapTok = new TypeToken<Map<?, ?>>() {};

        System.out.println(stringListTok.getType());
        System.out.println(wildMapTok.getType());

        test1();


    }

    public static void test1(){
        StudentPO studentPO = new StudentPO();
        studentPO.setAge(18);
        studentPO.setName("nalu");

        StudentRepoImpl studentRepo = new StudentRepoImpl();


        TypeToken stringToken = TypeToken.of(String.class);

        TypeToken listToken1 = TypeToken.of(List.class);

        TypeToken listToken = TypeToken.of(List.class);

        Class stringClass = stringToken.getRawType(); // 获取原始类型，结果为 class java.lang.String

        Type stringType = stringToken.getType(); // 获取类型，结果为 java.lang.String

        Type listType = listToken.getType(); // 获取类型，结果为 java.util.List

    }

    public static void getInvokable() throws NoSuchMethodException {
        Method method = StudentRepoImpl.class.getMethod("insert", String.class, int.class);
    }

    public static void test2(){
        TypeToken<List<String>> typeToken = new TypeToken<List<String>>() {};
        Type type = typeToken.getType();
        System.out.println(type);
    }

}
